<template>
	<view class="">
		<view class="areabox">
			<textarea value="" placeholder="宝贝是否满足了您的期待？说说您的购买心得吧！" v-model="content" />
		</view>
		<view class="title">
			上传图片<text>最多9张</text>
		</view>
		<view class="imgbox">
			<UpLoadimg @successImg="successImg3" :imgList="imgList3" @deleteImg="deleteImg3" :imgMaxNum="9"></UpLoadimg>
		</view>
		<view class="submit" @click="submit">
			提交评论
		</view>
	</view>
</template>

<script>
	import {
		commentcommodity
	} from "../../api/api/index.js"
	import UpLoadimg from "../../components/UpLoadimg/index.vue"
	export default {
		data() {
			return {
				id: 0,
				settlement_id: 0,
				content: "",
				imgList3:[]
			}
		},
		onLoad(v) {
			this.id = v.id
			this.settlement_id = v.settlement_id
		},
		methods: {
			// 提交评论
			submit() {
				let imglist=[]
				let that=this
				for (let i = 0; i < this.imgList3.length; i++) {
					imglist.push(this.imgList3[i].url)
				}
				let imgs=imglist.toString()
				// console.log(imgs)
				// debugger
				uni.showLoading({
					title:"提交中"
				})
				let data = {
					id: this.id,
					content: this.content,
					settlement_id: this.settlement_id,
					imgs:imgs
				}
				commentcommodity(data).then(res=>{
					uni.hideLoading()
					setTimeout(function(){
						that.jumpLink({link:"/pages/sucesssremark/index"})
					},1000)
				})
			},
			successImg3(data) {
				this.imgList3.push(data)
			},
			deleteImg3(index) {
				this.imgList3.splice(index, 1)
			},
		},
		components: {
			UpLoadimg
		}
	}
</script>

<style scoped lang="scss">
	.areabox {
		width: 700rpx;
		height: 332rpx;
		background-color: #ffffff;
		border-radius: 6rpx;
		margin-left: 25rpx;
		padding: 20rpx;
		margin-top: 25rpx;

		textarea {
			width: 100%;
		}
	}

	.title {
		font-family: MicrosoftYaHei-Bold;
		font-size: 28rpx;
		color: #333333;
		margin-left: 25rpx;
		margin-top: 55rpx;
		font-weight: 700;

		text {
			font-family: MicrosoftYaHei;
			font-size: 20rpx;
			color: #666666;
			margin-left: 20rpx;
			font-weight: 400;
		}
	}

	.imgbox {
		margin-left: 25rpx;
		margin-right: 25rpx;
	}

	.submit {
		margin: 95rpx auto;
		width: 586rpx;
		height: 70rpx;
		background-color: #ff7e65;
		border-radius: 35rpx;
		line-height: 70rpx;
		text-align: center;
		font-family: MicrosoftYaHei;
		font-size: 26rpx;
		color: #ffffff;
	}
</style>
